<template>
	<view class="background">
		<view class="content">
			<view class="my_main_header flex jcsb">
				<view class="flex jcsb aic" style="width: calc(100% - 70px);">
					<view class="my_main_dev">
						<p class="fonts18 fontw700 fontz" style="margin-bottom: 8px;">{{basic.name}}</p>
						<p class="fonts12 gray">{{basic.phonenumber}} | {{basic.jobSearchStatus}}</p>
						<p class="fonts12 gray">{{basic.age}} | {{basic.educationLevel}} | {{basic.startWorkTime}}</p>
						
						<view class="flex jcsb" style="margin-top: 17px;">
							<view class="flex flex_column jcc " @click="details(0)">
								<p class="fonts18 fontw700 fontz">{{basic.deliveredCount}}</p>
								<p class="fonts14 gray  fontz">已投递</p>
							</view>
							<view class="flex flex_column jcc " @click="details(1)">
								<p class="fonts18 fontw700 fontz">{{basic.invitedCount}}</p>
								<p class="fonts14 gray  fontz">邀请投递</p>
							</view>
							<view class="flex flex_column jcc " @click="details(2)">
								<p class="fonts18 fontw700 fontz">{{basic.collectedCount}}</p>
								<p class="fonts14 gray  fontz">收藏</p>
							</view>
						</view>
					</view>
				</view>
				<view class="my_image">
					<image v-if="basic.imageUrl" :src="basic.imageUrl" mode=""></image>
					<image v-else src="../../static/touxiang.png" mode=""></image>
				</view>
			</view>
			<view class="report_main_">
				<view class="report_mains flex aic jcsb" v-for="(item,index) in datas" :key="index" @click="detail(item)">
					<view class="flex report_mains_left flex aic">
						<image v-if="item.type==0" src="@/static/fj.png" mode=""></image>
						<image v-if="item.type==1" src="@/static/kb.png" mode=""></image>
						<image v-if="item.type==2" src="@/static/set.png" mode=""></image>
						<image v-if="item.type==3" src="@/static/my1.png" mode=""></image>
						<text class="fonts14 fontz ">{{item.name}}</text>
					</view>
					<image src="@/static/r1.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		getLogin,
		getInfo
	} from "@/api/login"
	import {
		dictFun
	} from "@/util/dictionary"
	export default {
		data() {
			return {
				basic: {
					user:{
						
					},
				},
				datas:[
					{
						name:"我的简历",
						type:"0",
						url:"/pages/my/resume/resume"
					},
					{
						name:"投递进度",
						type:"1",
						url:"/pages/my/schedule/schedule"
					},{
						name:"设置",
						type:"2",
						url:"/pages/my/setting/setting"
					},{
						name:"意见反馈",
						type:"3",
						url:"/pages/my/opinion/opinion"
					}
				]
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.getInfo_()
		},
		methods: {
			getInfo_() {
				getInfo().then(res => {
					console.log("个人信息", res);
					uni.setStorageSync("my_userInfo", res.data)
					this.info()
				})
			},
			info(){
				let obj = uni.getStorageSync("my_userInfo")
				console.log(obj);
				let personalInformation=obj.resumeVo.personalInformation
				let object={
					phonenumber:obj.user?obj.user.phonenumber?obj.user.phonenumber:"":"",
					name:personalInformation?personalInformation.fullName?personalInformation.fullName:"无名氏":"无名氏",
					deliveredCount:obj.deliveredCount,
					invitedCount:obj.invitedCount,
					collectedCount:obj.collectedCount,
					imageUrl:obj.user?obj.user.avatar?obj.user.avatar:"":"",
					age:personalInformation?personalInformation.age?personalInformation.age:"暂无年龄信息":"暂无年龄信息",
					educationLevel:this.educationLevelFun(obj.resumeVo.educationExperiences),
					startWorkTime:this.startWorkTimeFun(personalInformation?personalInformation.startWorkTime:""),
					jobSearchStatus:this.jobSearchStatusFun(personalInformation?personalInformation.jobSearchStatus:"")
				}
				this.basic=object
			},
			educationLevelFun(res){
				if(res.length!=0){
					console.log(res);
					let number=res[res.length-1].educationLevel?res[res.length-1].educationLevel:""
					if(number==""){
						return "暂无学历信息"
					}else{
						if(this.dictFuns(number,"education")){
							return this.dictFuns(number,"education")
						}else{
							return "暂无学历信息"
						}
						
					}
				}else{
					return "暂无学历信息"
				}
			},
			jobSearchStatusFun(res){
				if(res.length!=0){
					console.log(res);
					let number=res
					if(number==""){
						return "暂无工作状态"
					}else{
						if(this.dictFuns(number,"status_of_job_hunting")){
							return this.dictFuns(number,"status_of_job_hunting")
						}else{
							return "暂无工作状态"
						}
						
					}
				}else{
					return "暂无工作状态"
				}
			},
			startWorkTimeFun(res){
				if(res){
					let number=0
					let date=new Date()
					let year = date.getFullYear();
					number=year-res.split("-")[0]
					if(number==0){
						return ""
					}else{
						return number +"年工作经验"
					}
					
				}else{
					return ""
				}
				let date=new Date()
			},
			dictFuns(value,res){
				return dictFun(value, res)
			},
			details(index){
				if(index==0){
					uni.navigateTo({
						url: "/pages/my/delivered/delivered"
					})
				}else if(index==1){
					uni.navigateTo({
						url: "/pages/my/invitation/invitation"
					})
				}else{
					uni.navigateTo({
						url: "/pages/my/collect/collect"
					})
				}
			},
			backLogin() {
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
				
			detail(item){
				uni.navigateTo({
					url: item.url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my_main_header {
		padding-top: 54px;

		.my_image {
			position: relative;

			image {
				width: 70px;
				height: 70px;
				border-radius: 50%;
				margin-top: 6px;
			}
		}

	}

	.my_main_dev {
		width: 80%;
	}
	.report_main_{
		margin-top: 20px;
	}
	.report_mains {
		padding: 0px 14px;
		height: 60px;
		background: #FFFFFF;
		border-radius: 0px 0px 0px 0px;
		opacity: 1;

		.report_mains_left {
			image {
				width: 16px;
				height: 16px;
				margin-right: 8px;
			}
		}

		image {
			width: 20px;
			height: 20px;
		}
	}
</style>
